package wowmobile;

public class Action {

    public static final int STOP = 0;
    public static final int UP = 1;
    public static final int DOWN = 2;
    public static final int LEFT = 3;
    public static final int RIGHT = 4;
    private int move;
    private int menuOption;

    public int getMenuOption() {
        return menuOption;
    }

    public void setMenuOption(int menuOption) {
        this.menuOption = menuOption;
    }

    public Action() {
        move = Action.STOP;
    }

    public Action(int move, int menuOption) {
            this.move = move;
            this.menuOption=menuOption;
    }

    public void setMove(int move) {
            this.move = move;
    }

    public int getMove() {
        return move;
    }

    public String toString() {
        String tmp = "" + move;
        return tmp;
    }

    public static Action fromString(String s) {
        int move, menuOption=0;
        if (s.equals("0")) {
            move = 0;
        } else if (s.equals("1")) {
            move = 1;
        } else if (s.equals("2")) {
            move = 2;
        } else if (s.equals("3")) {
            move = 3;
        } else if (s.equals("4")) {
            move = 4;
        } else if(s.equals("6")) {
            move=6;
        } else if (s.startsWith("5")) {
            move=5;
            menuOption=Integer.parseInt(s.substring(1));
        } else {
            System.out.println("AAAA");
            return new Action();
        }

        return new Action(move,menuOption);
    }
}
